<template>
  <div>
    <a-table
      ref="table"
      size="middle"
      bordered
      rowKey="id"
      class="j-table-force-nowrap"
      :scroll="{ x: true }"
      :columns="packagingColumns"
      :dataSource="packagingList"
    >
    </a-table>
  </div>
</template>

<script>
import '@/assets/less/TableExpand.less'
import { getAction } from '@api/manage'

export default {
  name: 'packaging',
  data() {
    return {
      description: '包材清单',
      packagingList: [],
      packagingColumns: [
        {
          title: '#',
          dataIndex: '',
          key: 'rowIndex',
          width: 40,
          align: 'center',
          fixed: 'left',
          customRender: function (t, r, index) {
            return parseInt(index) + 1
          },
        },
        {
          title: '物料编码',
          dataIndex: 'packageCode',
          align: 'center',
        },
        {
          title: '物料名称',
          dataIndex: 'packageName',
          align: 'center',
        },
        {
          title: '规格型号',
          dataIndex: 'noneSpec',
          align: 'center',
        },
        {
          title: '是否自带',
          dataIndex: 'isBrought',
          align: 'center',
        },
        {
          title: '包材类别',
          dataIndex: 'packageInOutType',
          align: 'center',
        },
        {
          title: '比例数量',
          dataIndex: 'proportion',
          align: 'center',
        },
        {
          title: '损耗率(%)',
          dataIndex: 'lossRate',
          align: 'center',
        },
        {
          title: '材质',
          dataIndex: 'materialQuality',
          align: 'center',
        },
        {
          title: '尺寸',
          dataIndex: 'size',
          align: 'center',
        },
        {
          title: '版样代码',
          dataIndex: 'patternFile',
          align: 'center',
        },
        {
          title: '制单人',
          align: 'center',
          dataIndex: 'createBy_dictText',
        },
        {
          title: '制单人部门',
          align: 'center',
          dataIndex: 'sysOrgCode_dictText',
        },
        {
          title: '制单日期',
          align: 'center',
          dataIndex: 'createTime',
          customRender: function (text) {
            return !text ? '' : text.length > 10 ? text.substr(0, 10) : text
          },
        },
      ],
      url: {
        packagelist: '/pro/tslProWorkshopPlan/queryPackagebatchNumber',
      },
    }
  },
  methods: {
    loadpackagingData(batchNumber) {
      this.packagingList = []
      if (batchNumber) {
        getAction(this.url.packagelist, { batchNumber: batchNumber }).then((res) => {
          if (res.success) {
            this.packagingList = res.result.records || res.result || []
          }
        })
      }
    },
  },
}
</script>
<style scoped>
@import '~@assets/less/common.less';
::v-deep .ant-table-tbody tr {
  height: 36px !important;
}
</style>
